// components/dict-select/index.js
const App = getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    code: {
      type: String,
      value: 'fwlb'
    },
    label:{
      type:String,
      value:'标题'
    },
    isSubmit:{
      type:Boolean,
      value:false
    }
  },

  pageLifetimes:{
    show:function(){
      let dict = App.globalData.dictTree
        for (let i = 0; i < dict.length; i++) {
          if (dict[i].sKey == this.properties.code) {
            this.setData({
              columns: dict[i].Child
            })
          }
        }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    defaultIndex:0,
    showDialog:false,
    value:'',
    columns: [{
      sName: '测试',
      sKey: 1
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    openDialog(){
      this.setData({
        showDialog:true
      })
    },
    closeAreaPop(){
      this.setData({
        showDialog:false
      })
    },
    onChange: function () {},
    onConfirm: function (e) {
      this.setData({
        showDialog: false,
        value: e.detail.value.sName
      })
      this.triggerEvent('submit', {
        name: e.detail.value.sName,
        code: e.detail.value.sKey
      })

    }
  }
})